home *** CD-ROM | disk | FTP | other *** search
/ Mac Magazin/MacEasy 26 / Mac Magazin and MacEasy Magazine CD - Issue 26.iso / Wissenschaft & Technik / Mercutio_v1.3f / Sample Codeƒ / MercutioAPI.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-09-03  |  5.0 KB  |  175 lines  |  [TEXT/CWIE]

  1. /***********************************************************************************
  2. **
  3. **       Developer's Programming Interface for Mercutio Menu Definition Function
  4. **               © 1992-1996 Ramon M. Felciano, All Rights Reserved
  5. **                         C port -- January 17, 1994
  6. **
  7. ************************************************************************************/
  8.  
  9. /*
  10. **  03Sep96 : Bryan Pietrzak (U S WEST Marketing Resources Group)
  11. **  Changed MenuHandle to MenuRef to support STRICT_MENUS
  12. **
  13. **  11Jul96 : Uwe Hees
  14. **    Added Menus.h to compile seperately.
  15. **  Added struct alignment support to force mac68k struct alignment.
  16. **  Activated interface to MDEF_SetCallbackProc for use with UPPs.
  17. */
  18.  
  19. #ifndef __MercutioAPI__
  20. #define __MercutioAPI__
  21.  
  22. #ifndef __MENUS__
  23. #include <Menus.h>
  24. #endif
  25.  
  26. #ifdef __cplusplus
  27. extern "C" {
  28. #endif
  29.  
  30. #if PRAGMA_ALIGN_SUPPORTED
  31. #pragma options align=mac68k
  32. #endif
  33.  
  34. #define        customDefProcSig    'CUST'
  35. #define        areYouCustomMsg        (short) ('*' * 256 + '*')
  36. #define        getVersionMsg        (short) ('*' * 256 + 'v')
  37. #define        setCallbackMsg        (short) ('*' * 256 + 'c')
  38. #define        stripCustomDataMsg    (short) ('*' * 256 + 'd')
  39. #define        getCopyrightMsg        (short) ('C' * 256 + 'C')
  40. #define        setPrefsMsg            (short) ('*' * 256 + 'p')
  41. #define        setKeyGraphicsMsg    (short) ('*' * 256 + 'g')
  42. #define        setSmallIconIDMsg    (short) ('*' * 256 + 'i')
  43.  
  44.  
  45. #define        mMenuKeyMsg            (short) ('S' * 256 + 'K')
  46. #define        mDrawItemStateMsg    (short) ('S' * 256 + 'D')
  47. #define        mCountItemMsg        (short) ('S' * 256 + 'C')
  48.  
  49. #define        cbBasicDataOnlyMsg    1
  50. #define        cbIconOnlyMsg        2
  51. #define        cbGetLongestItemMsg 3
  52.  
  53. typedef struct {
  54.         Style    s;
  55.         SignedByte    filler;
  56.     } FlexStyle;
  57.     
  58. typedef struct {
  59.         FlexStyle    isDynamicFlag;
  60.         FlexStyle    forceNewGroupFlag;
  61.         FlexStyle    useCallbackFlag;
  62.         FlexStyle    controlKeyFlag;
  63.         FlexStyle    optionKeyFlag;
  64.         FlexStyle    shiftKeyFlag;
  65.         FlexStyle    cmdKeyFlag;
  66.         FlexStyle    unusedFlag;
  67.         short    requiredModifiers;
  68.         UInt32    unused2;
  69.         UInt32    unused3;
  70.     } MenuPrefsRec, *MenuPrefsPtr;
  71.  
  72. typedef    struct    {    // PACKED RECORD
  73.         char    iconID;
  74.         char    keyEq;
  75.         char    mark;
  76.         Style    textStyle;
  77.     } StdItemData, *StdItemDataPtr;
  78.  
  79.  
  80.  
  81. // ItemFlagsRec is a 2-byte sequence of 1-bit flags. It is defined
  82. // as a short here; use these constants to set the flags.
  83.  
  84. // high byte
  85. #define    kForceNewGroup    0x8000
  86. #define    kIsDynamic        0x4000
  87. #define    kUseCallback    0x2000
  88. #define    kControlKey        0x1000
  89. #define    kOptionKey        0x0800
  90. #define    kUnused10        0x0400
  91. #define kShiftKey        0x0200
  92. #define    kCmdKey            0x0100
  93. // low byte
  94. #define    kIsHier            0x0080
  95. #define    kChangedByCallback    0x0040
  96. #define    kEnabled        0x0020
  97. #define    kHilited        0x0010
  98. #define    kIconIsSmall        0x0008
  99. #define    kHasIcon        0x0004
  100. #define    kUnused1        0x0002
  101. #define    kUnused0        0x0001
  102.  
  103. typedef    struct    {
  104.         char    iconID;
  105.         char    keyEq;
  106.         char    mark;
  107.         FlexStyle    textStyle;
  108.         short    itemID;
  109.         Rect    itemRect;
  110.         short    flags;
  111.         ResType    iconType;
  112.         Handle    hIcon;
  113.         StringPtr pString;
  114.         Str255    itemStr;
  115.         short    cbMsg;
  116.     } RichItemData, *RichItemPtr;
  117.  
  118.     
  119. // UPP Callback    
  120. #if GENERATINGCFM
  121. typedef UniversalProcPtr MercutioCallbackUPP;
  122. #else
  123. typedef ProcPtr MercutioCallbackUPP;
  124. #endif
  125.  
  126. enum
  127. {
  128.     uppMercutioCallbackProcInfo = kPascalStackBased
  129.         | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(short)))
  130.         | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(short)))
  131.         | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(RichItemData*)))
  132. };
  133. // 3712 // $E80
  134. #if GENERATINGCFM
  135. #define NewMercutioCallback(userRoutine)    \
  136.     (MercutioCallbackUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppMercutioCallbackProcInfo, GetCurrentArchitecture())
  137. #define CallMercutioCallback(userRoutine, menuID, prevModifiers, richItemData)    \
  138.     CallUniversalProc((UniversalProcPtr)(userRoutine), uppMercutioCallbackProcInfo, (menuID), (prevModifiers), (richItemData))
  139. #else
  140. #define NewMercutioCallback(userRoutine)    \
  141.     ((MercutioCallbackUPP)(userRoutine))
  142. #define CallMercutioCallback(userRoutine, menuID, prevModifiers, richItemData)    \
  143.     (*(userRoutine)) ((menuID), (prevModifiers), (richItemData))
  144. #endif
  145. // END UPP Callback
  146.  
  147. extern pascal long MDEF_GetVersion(MenuRef menu);
  148. extern pascal StringHandle MDEF_GetCopyright(MenuRef menu);
  149. extern pascal Boolean    MDEF_IsCustomMenu(MenuRef menu);
  150.  
  151. extern pascal long    MDEF_MenuKey(long theMessage, short theModifiers, MenuRef hMenu);
  152.                     
  153. extern pascal void    MDEF_CalcItemSize(MenuRef hMenu, short item, Rect *destRect);
  154. extern pascal void    MDEF_DrawItem(MenuRef hMenu, short item, Rect destRect);
  155. extern pascal void    MDEF_DrawItemState(MenuRef hMenu, short item, Rect destRect, Boolean isHilited, Boolean isEnabled);
  156.  
  157. extern pascal void    MDEF_StripCustomData(MenuRef hMenu);
  158.  
  159. // Changed to do UPP
  160. extern pascal void    MDEF_SetCallbackProc(MenuRef hMenu, MercutioCallbackUPP mercutioCallback);
  161. //extern pascal void    MDEF_SetCallbackProc(MenuRef hMenu, ProcPtr theProc);
  162. extern pascal void    MDEF_SetMenuPrefs(MenuRef hMenu, MenuPrefsRec *thePrefs);
  163.  
  164. extern pascal void MDEF_SetKeyGraphicsPreference (MenuRef menu, Boolean preferGraphics);
  165. extern pascal void MDEF_SetSmallIconID (MenuRef menu, short iconsSmallAboveID);
  166.  
  167. #if PRAGMA_ALIGN_SUPPORTED
  168. #pragma options align=reset
  169. #endif
  170.  
  171. #ifdef __cplusplus
  172. }
  173. #endif
  174.  
  175. #endif